//package com.vilicode.Utils;
//
//import org.apache.hadoop.conf.Configuration;
//import org.apache.hadoop.fs.Path;
//import org.apache.hadoop.hbase.HBaseConfiguration;
//import org.apache.hadoop.hbase.client.Connection;
//import org.apache.hadoop.hbase.client.ConnectionFactory;
//import java.io.IOException;
//import java.net.URISyntaxException;
//
//
//public class HbaseConnectionUtil {
//    private static Configuration config;
//    private static Connection connection;
//    private static HbaseConnectionUtil INSTANCE = new HbaseConnectionUtil();
//    public static HbaseConnectionUtil getInstance() {
//        return INSTANCE;
//    }
//    static {
//        String[] files = {"core-site.xml","hbase-site.xml","hdfs-site.xml"};
//        initConfig(files);
//    }
//    public static void initConfig(String[]files){
//        config = HBaseConfiguration.create();
//        try {
//            for (String file:files) {
//                config.addResource(new
//                        Path(ClassLoader.getSystemResource(file).toURI()));
//            }
//        } catch (URISyntaxException e) {
//            e.printStackTrace();
//        }
//    }
//    public static Connection getConnection() throws IOException {
//        if (connection == null){
//            synchronized (HbaseConnectionUtil.class){
//                if (connection == null){
//                    connection = ConnectionFactory.createConnection(config);
//                }
//            }
//        }
//        return connection;
//    }
//
//}
